import http from "@/api";
import {AuthOperation, Menu, SysUserInfo} from "@/interface/api";

/**
 * 用户管理模块
 */

// 获取用户菜单列表
export const menuListApi = () => {
    return http.get<Menu[]>(`/sys_user/menus`);
};

// 获取用户操作权限列表
export const operationsApi = () => {
    return http.get<AuthOperation>(`/sys_user/operations`);
};

export const changePwdApi = (data: object) => {
    return http.post(`/sys_user/change_pwd`, data);
}

/**
 * 系统用户分页列表
 */
export const sysUserPageListApi = (params: object) => {
    return http.get(`/sys_user/paging`, params);
};

/**
 * 系统用户列表
 */
export const sysUserListApi = (params: object) => {
    return http.get(`/sys_user/list`, params);
};

/**
 * 保存系统用户
 * @param params
 */
export const saveSysUserApi = (params: object) => {
    return http.post(`/sys_user/save`, params);
};

/**
 * 编辑系统用户
 * @param params
 */
export const editSysUserApi = (params: any) => {
    return http.put<SysUserInfo>(`/sys_user/edit/${params.id}`, params);
};

/**
 * 切换系统用户状态
 * @param id
 */
export const changeStatusApi = (id: number) => {
    return http.put(`/sys_user/change_status/${id}`);
};

/**
 * 删除系统用户
 * @param id
 */
export const deleteSysUserByIdApi = (id: number) => {
    return http.delete(`/sys_user/delete/${id}`);
};

/**
 * 批量删除
 * @param params
 */
export const deleteSysUserApi = (params: object) => {
    return http.post(`/sys_user/delete`, params);
};